/**
 * 在[L, R]内找一个三个质数的积
 * 规模在100以内。直接暴力即可。
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

template<typename T>
void input(vector<T> & v, int n){
	v.assign(n + 1, {});
	for(int i=1;i<=n;++i) cin >> v[i];
	return;
}

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const vi P {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
vi B;

void init(){
	for(int i=0;i<14;++i)for(int j=0;j<14;++j)for(int k=0;k<14;++k){
		if(i != j and i != k and j != k){
			llt t = (llt)P[i] * P[j] * P[k];
			if(t <= 100) B.emplace_back(t);
		}
        
	}
	sort(B.begin(), B.end());
	B.erase(unique(B.begin(), B.end()), B.end());
}

void work(){
    int a, b; cin >> a >> b;
	auto pa = equal_range(B.begin(), B.end(), a);
	auto pb = equal_range(B.begin(), B.end(), b);
	if(pa.first != pb.second){
		cout << *pa.first << endl;
	}else{
		cout << "-1\n";
	}
	return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int nofkase = 1;
    // cin >> nofkase;
	init();
    while(nofkase--) work();
    return 0;
}